package com.caregiver.watch.business.care.controller;

import com.caregiver.watch.business.care.model.dto.AddFenceSettingParam;
import com.caregiver.watch.business.care.model.dto.DeleteFenceSettingParam;
import com.caregiver.watch.business.care.model.dto.EnableFenceSettingParam;
import com.caregiver.watch.business.care.model.dto.FenceRecipientInfo;
import com.caregiver.watch.business.care.model.dto.UpdateFenceSettingParam;
import com.caregiver.watch.business.care.model.vo.FenceRecipientVo;
import com.caregiver.watch.business.care.model.vo.FenceSettingDetailVo;
import com.caregiver.watch.business.care.model.vo.FenceSettingVo;
import com.caregiver.watch.business.care.service.FenceService;
import com.caregiver.watch.common.domain.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @program: caregiver-watch
 * @author: 疆戟
 * @create: 2025-10-05 20:01
 */
@Tag(name  = "CareConfigController", description = "照护配置")
@RestController
@RequestMapping("/care/config")
public class CareConfigController {

    @Autowired
    private FenceService fenceService;

    @Operation(summary = "查询围栏设置列表")
    @GetMapping("queryFenceSettingList")
    public R<List<FenceSettingVo>> queryFenceSettingList() {
        return R.ok(fenceService.queryFenceSettingList());
    }


    // 查询围栏设置
    @Operation(summary = "查询围栏设置")
    @GetMapping("/queryFenceSetting")
    public R<FenceSettingDetailVo> queryFenceSetting(@RequestParam(value = "fenceId") Long fenceId) {
        return R.ok(fenceService.queryFenceSetting(fenceId));
    }

    // 添加围栏设置
    @Operation(summary = "添加围栏设置")
    @PostMapping("/addFenceSetting")
    public R<Boolean> addFenceSetting(@RequestBody AddFenceSettingParam param) {
        return R.ok(fenceService.addFenceSetting(param));
    }

    // 修改围栏设置
    @Operation(summary = "修改围栏设置")
    @PostMapping("/updateFenceSetting")
    public R<Boolean> updateFenceSetting(@RequestBody UpdateFenceSettingParam param) {
        return R.ok(fenceService.updateFenceSetting(param));
    }

    @Operation(summary = "开启/关闭围栏设置")
    @PostMapping("/enableFenceSetting")
    public R<Boolean> enableFenceSetting(@RequestBody EnableFenceSettingParam param) {
        return R.ok(fenceService.enableFenceSetting(param));
    }
    // 删除围栏设置
    @Operation(summary = "删除围栏设置")
    @PostMapping("/deleteFenceSetting")
    public R<Boolean> deleteFenceSetting(@RequestBody DeleteFenceSettingParam param) {
        return R.ok(fenceService.deleteFenceSetting(param));
    }


    @Operation(summary = "获取生效对象列表")
    @GetMapping("/queryFenceRecipientList")
    public R<FenceRecipientVo> queryFenceRecipientList() {
        return R.ok(fenceService.queryFenceRecipientList());
    }
}
